using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace Curchy.PERTToolbox.Service
{
    public class PersistanceToolbox<T>
    {
        public static T Load(string filename)
        {
            TextReader reader = new StreamReader(filename);
            XmlSerializer ser = new XmlSerializer(typeof(T));
            T toReturn = (T)ser.Deserialize(reader);
            reader.Close();
            return toReturn;
        }

        public static void Save(T o, string filename)
        {
            TextWriter writer = new StreamWriter(filename);
            XmlSerializer ser = new XmlSerializer(typeof(T));
            ser.Serialize(writer, o);
            writer.Close();
        }
    }
}
